<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="108px"
    >
      <el-form-item label="标准号" prop="a100">
        <el-input
          v-model="queryParams.a100"
          placeholder="请输入标准号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="中文标准名称" prop="a298" >
        <el-input
          v-model="queryParams.a298"
          placeholder="请输入中文标准名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="发布日期" prop="a101">
        <el-input
          v-model="queryParams.a101"
          placeholder="请输入发布日期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="标准状态" prop="a200">
        <el-select v-model="queryParams.a200" placeholder="请输入标准状态" clearable>
          <el-option
            v-for="dict in dict.type.standard_a200"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:db15:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:db15:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:db15:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:db15:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="db15List"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="标准号" align="center" prop="a100" >
          <template slot-scope="scope">
             <div v-html="scope.row.a100"></div>
        </template>
      </el-table-column>
      <el-table-column label="发布日期" align="center" prop="a101" />
      <el-table-column label="标准状态" align="center" prop="a200" >
        <template slot-scope="scope">
          <div v-if="scope.row.a200 == '现行'" style="color:#4c9e5c;font-weight:bold;">{{scope.row.a200}}</div>
          <div v-if="scope.row.a200 == '废止'" style="color:red;font-weight:bold;">{{scope.row.a200}}</div>
          <div v-if="scope.row.a200 == '未生效'" style="color:blue;font-weight:bold;">{{scope.row.a200}}</div>
          <div v-if="scope.row.a200 == '作废'" style="color:red;font-weight:bold;">{{scope.row.a200}}</div>
          <div v-if="scope.row.a200 == '已转化为团标'" style="color:red;font-weight:bold;">{{scope.row.a200}}</div>
        </template>
      </el-table-column>
      <el-table-column label="中文标准名称" align="center" prop="a298" >
          <template slot-scope="scope">
             <div v-html="scope.row.a298"></div>
          </template>
      </el-table-column>
      <el-table-column label="英文标准名称" align="center" prop="a302" />
      <el-table-column label="中国标准分类号" align="center" prop="a825" />
      <el-table-column label="国际标准分类号" align="center" prop="a826" />
      <el-table-column label="虚拟文件路径" align="center" prop="a893" />
      <el-table-column label="电子标准文件" align="center" prop="filePath" :formatter="fileFormatter">
          <template slot-scope="scope">
             <div v-if="scope.row.filePath!=null && scope.row.filePath.startsWith('http')">
              <a target="_blank" v-bind:href="scope.row.filePath + '?response-content-disposition=inline&response-content-type=application/pdf'" @click="handleFileClick(scope.row, $event)">预览</a>
              &#12288;&#12288;
              <a target="_blank" v-bind:href="scope.row.filePath" @click="handleFileClick(scope.row, $event)">下载</a>
             </div>
          </template>

      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:db15:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleStruct(scope.row)"
            v-hasPermi="['system:standardStruct:edit']"
          >添加结构化数据</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleStructUpdate(scope.row)"
            v-hasPermi="['system:standardStruct:edit']"
          >修改结构化数据</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:db15:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改Standard对话框 -->
    <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false"  width="100%" append-to-body>
      <el-row>
        <el-col :span="13">
          <!-- <pdf
              v-for="item in pageTotal"
              :src="pdfUrl"
              :key="item"
              :page="item"
          >
          </pdf> -->
          <iframe :src="pdfUrl" style="width:100%;height:1100px;"></iframe>
        </el-col>
        <el-col :span="11">
          <el-form ref="form" :model="form" :rules="rules" label-width="150px">
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="记录状态" prop="a000">
                  <el-input v-model="form.a000" placeholder="请输入记录状态" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="记录识别符" prop="a001">
                  <el-input v-model="form.a001" placeholder="请输入记录识别符" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="记录日期" prop="a003">
                  <el-input v-model="form.a003" placeholder="请输入记录日期" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="ISBN" prop="a010">
                  <el-input v-model="form.a010" placeholder="请输入ISBN" />
                </el-form-item>
              </el-col>
            </el-row> -->
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="ISNN" prop="a011">
                  <el-input v-model="form.a011" placeholder="请输入ISNN" />
                </el-form-item>
              </el-col> -->
              <el-col :span="24">
                <el-form-item label="标准号" prop="a100">
                  <el-input v-model="form.a100" placeholder="请输入标准号" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="发布日期" prop="a101">
                  <el-date-picker clearable
                      v-model="form.a101"
                      type="date"
                      value-format="yyyy-MM-dd"
                      placeholder="请输入发布日期">
                    </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="实施日期" prop="a205">
                  <el-date-picker clearable
                      v-model="form.a205"
                      type="date"
                      value-format="yyyy-MM-dd"
                      placeholder="请输入实施日期">
                    </el-date-picker>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="12">
                <el-form-item label="发布机构" prop="a102">
                  <el-input v-model="form.a102" placeholder="请输入发布机构" />
                </el-form-item>
              </el-col> -->
            </el-row>
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="发布机构代码" prop="a104">
                  <el-input v-model="form.a104" placeholder="请输入发布机构代码" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="版本" prop="a103">
                  <el-input v-model="form.a103" placeholder="请输入版本" />
                </el-form-item>
              </el-col>
            </el-row> -->
            <!--<el-row>

               <el-col :span="12">
                <el-form-item label="有效区域" prop="a203">
                  <el-input v-model="form.a203" placeholder="请输入有效区域" />
                </el-form-item>
              </el-col> 
            </el-row>-->
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="批准单位" prop="a204">
                  <el-input v-model="form.a204" placeholder="请输入批准单位" />
                </el-form-item>
              </el-col> -->



              <el-col :span="12">
                <el-form-item label="废止日期" prop="a206">
                  <el-date-picker clearable
                    v-model="form.a206"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请输入废止日期">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="发布单位" prop="a102">
                  <el-input v-model="form.a102" placeholder="请输入发布单位" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="截止日期" prop="a210">
                  <el-date-picker clearable
                    v-model="form.a210"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请输入截止日期">
                  </el-date-picker>
                </el-form-item>
              </el-col> -->
              <el-col :span="24">
                <el-form-item label="中文标准名称" prop="a298">
                  <el-input v-model="form.a298" placeholder="请输入中文标准名称" />
                </el-form-item>
              </el-col>
            </el-row>
            
            <el-row>
              <el-col :span="24">
                <el-form-item label="英文标准名称" prop="a302">
                  <el-input
                    v-model="form.a302"
                    placeholder="请输入英文标准名称"
                  /> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="确认日期" prop="a207">
                  <el-date-picker clearable
                    v-model="form.a207"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请输入确认日期">
                  </el-date-picker>
                </el-form-item>
              </el-col> -->
                            <el-col :span="24">
                <el-form-item label="起草单位" prop="a209">
                  <el-input v-model="form.a209" placeholder="请输入起草单位" />
                </el-form-item>
              </el-col>
            </el-row>
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="原分类号" prop="a208">
                  <el-input v-model="form.a208" placeholder="请输入原分类号" />
                </el-form-item>
              </el-col>

            </el-row> -->
            <el-row>
              <el-col :span="24">
                <el-form-item label="起草人" prop="a895">
                  <el-input v-model="form.a895" placeholder="请输入起草人" />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="文献出处" prop="a448">
                  <el-input
                    v-model="form.a448"
                    placeholder="请输入文献出处"
                  /> </el-form-item
              ></el-col> -->
              <el-col :span="12">
                <el-form-item label="代替标准" prop="a461">
                  <el-input
                    v-model="form.a461"
                    placeholder="请输入代替标准"
                  /> </el-form-item
              ></el-col>
                            <el-col :span="12">
                <el-form-item label="被代替标准" prop="a462">
                  <el-input
                    v-model="form.a462"
                    placeholder="请输入被代替标准"
                  /> </el-form-item
              ></el-col>
            </el-row>

            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="正文语种" prop="a300">
                  <el-input
                    v-model="form.a300"
                    placeholder="请输入正文语种"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="原文标准名称" prop="a301">
                  <el-input
                    v-model="form.a301"
                    placeholder="请输入原文标准名称"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="英文标准名称" prop="a302">
                  <el-input
                    v-model="form.a302"
                    placeholder="请输入英文标准名称"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="出版单位" prop="a304">
                  <el-input
                    v-model="form.a304"
                    placeholder="请输入出版单位"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="稽核项" prop="a305">
                  <el-input
                    v-model="form.a305"
                    placeholder="请输入稽核项"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="译文" prop="a309">
                  <el-input
                    v-model="form.a309"
                    placeholder="请输入译文"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <el-row>
              <el-col :span="12">
                <el-form-item label="价格(页数)" prop="a310">
                  <el-input
                    v-model="form.a310"
                    placeholder="请输入价格"
                  /> </el-form-item
              ></el-col>
              <!-- <el-col :span="12">
                <el-form-item label="其他载体" prop="a311">
                  <el-input
                    v-model="form.a311"
                    placeholder="请输入其他载体"
                  /> </el-form-item
              ></el-col> -->
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="适用范围" prop="a330">
                  <el-input
                    v-model="form.a330"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col>
              <!-- <el-col :span="12">
                <el-form-item label="英文文摘" prop="a331">
                  <el-input
                    v-model="form.a331"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col> -->
            </el-row>
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="英文主题词" prop="a390">
                  <el-input
                    v-model="form.a390"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="附注" prop="a409">
                  <el-input
                    v-model="form.a409"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            
            <!-- <el-row>

              <el-col :span="12">
                <el-form-item label="引用文件" prop="a502">
                  <el-input
                    v-model="form.a502"
                    placeholder="请输入引用文件"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="相关法律" prop="a505">
                  <el-input
                    v-model="form.a505"
                    placeholder="请输入相关法律"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="一致性程度" prop="a800">
                  <el-input
                    v-model="form.a800"
                    placeholder="请输入一致性程度"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="第二标准号" prop="a805">
                  <el-input
                    v-model="form.a805"
                    placeholder="请输入第二标准号"
                  /> </el-form-item
              ></el-col> -->
              <el-col :span="24">
                <el-form-item label="前言" prop="a807">
                  <el-input
                    v-model="form.a807"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="引言" prop="a808">
                  <el-input
                    v-model="form.a808"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col>
              <!-- <el-col :span="12">
                <el-form-item label="修改件" prop="a820">
                  <el-input
                    v-model="form.a820"
                    placeholder="请输入修改件"
                  /> </el-form-item
              ></el-col> -->
            </el-row>
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="被修改件" prop="a821">
                  <el-input
                    v-model="form.a821"
                    placeholder="请输入被修改件"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="补充件" prop="a823">
                  <el-input
                    v-model="form.a823"
                    placeholder="请输入补充件"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="被补充件" prop="a824">
                  <el-input
                    v-model="form.a824"
                    placeholder="请输入被补充件"
                  /> </el-form-item
              ></el-col> -->
              <el-col :span="12">
                <el-form-item label="中国标准分类号" prop="a825">
                  <el-input
                    v-model="form.a825"
                    placeholder="请输入中国标准分类号"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="国际标准分类号" prop="a826">
                  <el-input
                    v-model="form.a826"
                    placeholder="请输入国际标准分类号"
                  /> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="标准状态" prop="a200">
                  <el-select v-model="form.a200" placeholder="请输入标准状态">
                    <el-option
                      v-for="dict in dict.type.standard_a200"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="12">
                <el-form-item label="中文主题词" prop="a835">
                  <el-input
                    v-model="form.a835"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col> -->
            </el-row>
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="中文自由词" prop="a840">
                  <el-input
                    v-model="form.a840"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="原文主题词" prop="a837">
                  <el-input
                    v-model="form.a837"
                    type="textarea"
                    placeholder="请输入内容"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="索取号" prop="a845">
                  <el-input
                    v-model="form.a845"
                    placeholder="请输入索取号"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="馆藏标志" prop="a846">
                  <el-input
                    v-model="form.a846"
                    placeholder="请输入馆藏标志"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="排序码" prop="a847">
                  <el-input
                    v-model="form.a847"
                    placeholder="请输入排序码"
                  /> </el-form-item
              ></el-col> -->
              <el-col :span="12">
                <el-form-item label="标准类型" prop="a850">
                  <!-- <el-input
                    v-model="form.a850"
                    placeholder="请输入标准类型"
                  /> -->
                  <el-select v-model="form.a850" placeholder="请输入标准类型">
                    <el-option
                      v-for="dict in dict.type.standard_a850"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                   </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="表名" prop="tableName">
                  <!-- <el-input
                    v-model="form.tableName"
                    placeholder="请输入tableName"
                  />  -->
                  <el-select v-model="form.tableName" placeholder="请输入表名">
                    <el-option
                      v-for="dict in dict.type.standard_tablename"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                  
                  </el-form-item
              ></el-col>
              <!-- <el-col :span="12">
                <el-form-item label="表名2" prop="table_name">
                  <el-input
                    v-model="form.table_name"
                    placeholder="请输入table_name"
                  /> </el-form-item
              ></el-col> -->
            </el-row>
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="文献类型" prop="a860">
                  <el-input
                    v-model="form.a860"
                    placeholder="请输入文献类型"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="卷期号" prop="a861">
                  <el-input
                    v-model="form.a861"
                    placeholder="请输入卷期号"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="文献代号" prop="a863">
                  <el-input
                    v-model="form.a863"
                    placeholder="请输入文献代号"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="出版周期" prop="a864">
                  <el-input
                    v-model="form.a864"
                    placeholder="请输入出版周期"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="出版地" prop="a865">
                  <el-input
                    v-model="form.a865"
                    placeholder="请输入出版地"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="密级" prop="a866">
                  <el-input
                    v-model="form.a866"
                    placeholder="请输入密级"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="提出单位" prop="a870">
                  <el-input
                    v-model="form.a870"
                    placeholder="请输入提出单位"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="归口单位" prop="a871">
                  <el-input
                    v-model="form.a871"
                    placeholder="请输入归口单位"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="国别" prop="a885">
                  <el-input
                    v-model="form.a885"
                    placeholder="请输入国别"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="标引依据" prop="a886">
                  <el-input
                    v-model="form.a886"
                    placeholder="请输入标引依据"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="12">
                <el-form-item label="更新批号" prop="a890">
                  <el-input
                    v-model="form.a890"
                    placeholder="请输入更新批号"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="标准历史" prop="a891">
                  <el-input
                    v-model="form.a891"
                    placeholder="请输入标准历史"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="参建单位" prop="a892">
                  <el-input
                    v-model="form.a892"
                    placeholder="请输入参建单位"
                  /> </el-form-item
              ></el-col>
            </el-row> -->
            <el-row>
              <el-col :span="24">
                <el-form-item label="电子文件名称" prop="filePath">
                  <file-upload  :limit="1" v-model="form.filePath" :on-success="handleUploadSuccess"/> </el-form-item>
                </el-col>
            </el-row>
          </el-form>
        </el-col>
      </el-row>
      
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!--添加修改结构化数据对话框-->

    <el-dialog :title="structtitle" :visible.sync="structopen" :close-on-click-modal="false"  width="100%" append-to-body>
      <el-row>
        <el-col :span="14">
          <!-- <pdf
              :src="structPdfUrl"
          >
          </pdf> -->
          <iframe :src="structPdfUrl + '?response-content-disposition=inline&response-content-type=application/pdf'" :style="{width: '100%', height: iframeHeight + 'px'}" type="application/pdf"></iframe>
          <!-- <embed
            v-if="structPdfUrl"
            :src="structPdfUrl"
            :style="{ width: '100%', height: `${iframeHeight}px` }"
            type="application/pdf"
            pluginspage="http://www.adobe.com/products/acrobat/readstep2.html"
          />
          <div v-else class="pdf-error">暂无有效 PDF 路径</div> -->
        </el-col>
        <el-col :span="10" :style="{height: iframeHeight + 'px', overflowY: 'auto'}">

          <el-form ref="formStruct" :model="formStruct" label-width="130px" style="padding:20px;" label-class="large-label">

            <!-- 添加按钮 -->
            <el-row>
              <el-col :span="24">
                <el-button type="primary" icon="el-icon-plus" @click="addGuifan">
                  添加规范性引用文件
                </el-button>
              </el-col>
            </el-row>
            <br>
            <!-- ------------------规范性引用文件---------------------- -->
            <el-row style="background-color: #817f7f3a;height:30px;line-height: 30px;">
               <el-col :span="4" style="text-align: center;">
                  <span>类型</span>
                </el-col>
                <el-col :span="18" style="text-align: left;">
                  <span>规范性引用文件条目</span>
                </el-col>
                <el-col :span="2" style="text-align: left;">
                  <span>操作</span>
                </el-col>
            </el-row>
            <br>
            <el-row v-for="(item, index) in formStruct.referenceFiles" :key="index">
              <el-row>
                <el-col :span="22">
                  <el-form-item :label="'规范性引用文件' + (index + 1)"  >
                  <!-- <el-form-item :label="'规范性引用文件' + (index + 1)" :prop="'referenceFiles.' + index" > -->
                    <el-input type="textarea" v-model="item.nDocum" placeholder="请输入规范性引用文件" />
                  </el-form-item>
                </el-col>
                <el-col :span="2" style="display: flex; align-items: center;">
                  <!-- 仅当有多个输入框时显示删除按钮 -->
                  <el-button  type="danger" icon="el-icon-delete" circle @click="removeGuifan(index)" />
                </el-col>
              </el-row>

            </el-row>

            <!-- ------------------规范性引用文件---------------------- -->
            <br>
            <!-- ------------------附录---------------------- -->
                        <!-- 添加按钮 -->
            <el-row>
              <el-col :span="24">
                <el-button type="success" icon="el-icon-plus" @click="addFulu">
                  添加附录
                </el-button>
              </el-col>
            </el-row>
            <br>
            <el-row style="background-color: #817f7f3a;height:30px;line-height: 30px;">
               <el-col :span="3" style="text-align: center;">
                  <span>类型</span>
                </el-col>
                <el-col :span="5" style="text-align: left;">
                  <span>附录编号</span>
                </el-col>
                <el-col :span="14" style="text-align: left;">
                  <span>附录内容</span>
                </el-col>
                <el-col :span="2" style="text-align: left;">
                  <span>操作</span>
                </el-col>
            </el-row>
                        <br>
            <el-row v-for="(item, index) in formStruct.fuluList" :key="index">
              <el-row>
                <el-col :span="7">
                  <el-form-item :label="'附录' + (index + 1)" label-width="80px">
                  <!-- <el-form-item> -->
                    <el-input v-model="item.appId" placeholder="附录编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="15">
                  <!-- <el-form-item :label="'附录内容' + (index + 1)"  > -->
                  <el-form-item label-width="40px">
                    <el-input type="textarea" v-model="item.appBody" placeholder="附录内容" />
                  </el-form-item>
                </el-col>
                <el-col :span="2" style="display: flex; align-items: center;">
                  <!-- 仅当有多个输入框时显示删除按钮 -->
                  <el-button  type="danger" icon="el-icon-delete" circle @click="removeFulu(index)" />
                </el-col>
              </el-row>

              
            </el-row>

            <!-- ------------------附录---------------------- -->
            <br>
            <!-- ------------------参考文献---------------------- -->
                        <!-- 添加按钮 -->
            <el-row>
              <el-col :span="24">
                <el-button type="warning" icon="el-icon-plus" @click="addCankao">
                  添加参考文献
                </el-button>
              </el-col>
            </el-row>
                        <br>
            <el-row style="background-color: #817f7f3a;height:30px;line-height: 30px;">
               <el-col :span="4" style="text-align: center;">
                  <span>类型</span>
                </el-col>
                <el-col :span="18" style="text-align: left;">
                  <span>参考文献条目</span>
                </el-col>
                <el-col :span="2" style="text-align: left;">
                  <span>操作</span>
                </el-col>
            </el-row>
            <br>
            <el-row v-for="(item, index) in formStruct.cankaoList" :key="index">
              <el-row>
                <el-col :span="22">
                  <el-form-item :label="'参考文献' + (index + 1)" >
                    <el-input type="textarea" v-model="item.refItem" placeholder="请输入参考文献" />
                  </el-form-item>
                </el-col>
                <el-col :span="2" style="display: flex; align-items: center;">
                  <!-- 仅当有多个输入框时显示删除按钮 -->
                  <el-button  type="danger" icon="el-icon-delete" circle @click="removeCankao(index)" />
                </el-col>
              </el-row>
            </el-row>



            <!-- ------------------参考文献---------------------- -->
            <br>
            <!-- ------------------引言---------------------- -->
            <!-- <el-row>
              <el-col :span="24">
                <el-button type="warning" icon="el-icon-plus" @click="addYinyan">
                  添加引言
                </el-button>
              </el-col>
            </el-row>
             <br>
            <el-row v-for="(item, index) in formStruct.yinyanList" :key="index">
              <el-row>
                <el-col :span="22">
                  <el-form-item :label="'引言' + (index + 1)"  >
                    <el-input type="textarea" v-model="item.introduction" placeholder="引言" />
                  </el-form-item>
                </el-col>
                <el-col :span="2" style="display: flex; align-items: center;">
                  <el-button  type="danger" icon="el-icon-delete" circle @click="removeYinyan(index)" />
                </el-col>
              </el-row>
            </el-row> -->
            <!-- 添加按钮 -->

            <!-- ------------------引言---------------------- -->
            <!-- <br> -->
            <!-- ------------------术语---------------------- -->
                        <!-- 添加按钮 -->
            <el-row>
              <el-col :span="24">
                <el-button type="primary" icon="el-icon-plus" @click="addShuyu">
                  添加术语
                </el-button>
              </el-col>
            </el-row>
             <br>
            <el-row style="background-color: #817f7f3a;height:30px;line-height: 30px;">
               <el-col :span="3" style="text-align: center;">
                  <span>类型</span>
                </el-col>
                <el-col :span="3" style="text-align: left;">
                  <span>条目编号</span>
                </el-col>
                <el-col :span="4" style="text-align: left;">
                  <span>术语名称</span>
                </el-col>
                <el-col :span="3" style="text-align: left;">
                  <span>英文名称</span>
                </el-col>
                <el-col :span="4" style="text-align: left;">
                  <span>术语定义</span>
                </el-col>
                <el-col :span="3" style="text-align: left;">
                  <span>注</span>
                </el-col>
                <el-col :span="2" style="text-align: left;">
                  <span>例</span>
                </el-col>
                <el-col :span="2" style="text-align: left;">
                  <span>操作</span>
                </el-col>
            </el-row>
            <br>
            <el-row v-for="(item, index) in formStruct.shuyuList" :key="index">
              <el-row>
                <el-col :span="5">
                  <el-form-item :label="'术语' + (index + 1)"  label-width="80px" >
                    <el-input v-model="item.tId" placeholder="条目编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item  label-width="10px" >
                    <el-input v-model="item.tCn" placeholder="术语中文名" />
                  </el-form-item>
                </el-col>
 
                <el-col :span="3">
                  <el-form-item label-width="10px"  >
                    <el-input v-model="item.tEn" placeholder="术语英文名" />
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item  label-width="10px" >
                    <el-input v-model="item.tDef" placeholder="术语定义" />
                  </el-form-item>
                </el-col>

                <el-col :span="3">
                  <el-form-item label-width="10px" >
                    <el-input v-model="item.tNote" placeholder="术语备注" />
                  </el-form-item>
                </el-col>
                <el-col :span="3">
                  <el-form-item label-width="10px"  >
                    <el-input v-model="item.tExp" placeholder="术语扩展" />
                  </el-form-item>
                </el-col>
                <el-col :span="2" style="display: flex; align-items: center;">
                  <!-- 仅当有多个输入框时显示删除按钮 -->
                  <el-button type="danger" icon="el-icon-delete" circle @click="removeShuyu(index)" />
                </el-col>
              </el-row>

            </el-row>
            <br>


            <!-- ------------------术语---------------------- -->


            <!-- ------------------目次---------------------- -->
                        <!-- 添加按钮 -->
            <el-row>
              <el-col :span="24">
                <el-button type="success" icon="el-icon-plus" @click="addMuci">
                  添加目次
                </el-button>
              </el-col>
            </el-row>
                        <br>
            <el-row style="background-color: #817f7f3a;height:30px;line-height: 30px;">
               <el-col :span="3" style="text-align: center;">
                  <span>类型</span>
                </el-col>
                <el-col :span="5" style="text-align: left;">
                  <span>目次条目编号</span>
                </el-col>
                <el-col :span="14" style="text-align: left;">
                  <span>目次条目内容</span>
                </el-col>
                <el-col :span="2" style="text-align: left;">
                  <span>操作</span>
                </el-col>
            </el-row>
            <br>
            <el-row v-for="(item, index) in formStruct.muciList" :key="index">
              <el-row>
                <el-col :span="7">
                  <el-form-item :label="'目次' + (index + 1)" label-width="80px" >
                    <el-input v-model="item.clgId" placeholder="目次" />
                  </el-form-item>
                </el-col>
                <el-col :span="15">
                  <!-- <el-form-item :label="'目次' + (index + 1)"  > -->
                  <el-form-item label-width="40px" >
                    <el-input v-model="item.clgName" placeholder="目次" />
                  </el-form-item>
                </el-col>
                <el-col :span="2" style="display: flex; align-items: center;">
                  <!-- 仅当有多个输入框时显示删除按钮 -->
                  <el-button type="danger" icon="el-icon-delete" circle @click="removeMuci(index)" />
                </el-col>
              </el-row>

            </el-row>

            <br>

            <!-- ------------------目次---------------------- -->



            <!-- ------------------结构化数据---------------------- -->
                        <!-- 添加按钮 -->
            <el-row>
              <el-col :span="24">
                <el-button type="primary" icon="el-icon-plus" @click="addJieGou">
                  添加结构化数据
                </el-button>
              </el-col>
            </el-row>
                                    <br>
            <el-row style="background-color: #817f7f3a;height:30px;line-height: 30px;">
               <el-col :span="4" style="text-align: center;">
                  <span>类型</span>
                </el-col>
                <el-col :span="4" style="text-align: left;">
                  <span>结构级别</span>
                </el-col>
                <el-col :span="4" style="text-align: left;">
                  <span>结构编号</span>
                </el-col>
                <el-col :span="4" style="text-align: left;">
                  <span>结构标题</span>
                </el-col>
                <el-col :span="6" style="text-align: left;">
                  <span>结构内容</span>
                </el-col>
                <el-col :span="2" style="text-align: left;">
                  <span>操作</span>
                </el-col>
            </el-row>
            <br>
            <el-row v-for="(item, index) in formStruct.jiegouList" :key="index">
              <el-row>
                <el-col :span="7">
                  <!-- <el-form-item :label="'结构化标题级别' + (index + 1)" :prop="'jiegou.' + index" >
                    <el-input v-model="item.techLevel" placeholder="结构化" />
                  </el-form-item> -->
                  <el-form-item :label="'结构化内容' + (index + 1)"  label-width="90px" >
                    <el-select v-model="item.techLevel" placeholder="请选择标题级别">
                      <el-option v-for="level in titleLevels" :key="level.value" :label="level.label" :value="level.value" />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item  label-width="10px" >
                    <el-input v-model="item.techItid" placeholder="结构化编号" />
                  </el-form-item>
                </el-col>

                <el-col :span="4">
                  <el-form-item label-width="10px"  >
                    <el-input v-model="item.techItname" placeholder="结构化标题" />
                  </el-form-item>
                </el-col>

                <el-col :span="7">
                  <el-form-item  label-width="10px" >
                    <el-input type="textarea" v-model="item.techPtbody" placeholder="结构化内容" />
                  </el-form-item>
                </el-col>
                <el-col :span="2" style="display: flex; align-items: center;">
                  <!-- 仅当有多个输入框时显示删除按钮 -->
                  <el-button  type="danger" icon="el-icon-delete" circle @click="removeJieGou(index)" />
                </el-col>
              </el-row>

            </el-row>



            <!-- ------------------结构化数据---------------------- -->

          </el-form>


        </el-col>
      </el-row>
      
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitStructForm">确 定</el-button>
        <el-button @click="cancelStruct">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script>
import {
  listDb15,
  getDb15,
  delDb15,
  addDb15,
  updateDb15,
  listStandard,
  getStandard,
  updateStandard
} from "@/api/system/db15";
import { addStandardStructList, getStandardStructBybid } from "@/api/system/standardStruct";
import { addDownLog } from "@/api/system/downLog";

import pdf from 'vue-pdf'
export default {
  name: "Db15",
  dicts: ['standard_a200','standard_a850','standard_tablename'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      structId: '',
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // Standard表格数据
      db15List: [],
      titleLevels: [
        { value: '1', label: '一级标题' },
        { value: '2', label: '二级标题' },
        { value: '3', label: '三级标题' },
        { value: '4', label: '四级标题' },
        { value: '5', label: '五级标题' },
        { value: '6', label: '六级标题' }
      ],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      structopen: false,
      structtitle: '',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        a100:this.a100,
        a298:this.a298,
        // "a302":this.a302,
        // "a895":this.a895,
        // "a209":this.a209,
        // "a825":this.a825,
        // "a826":this.a826,
        // "a200":this.a200
        // a000: null,
        // a001: null,
        // a003: null,
        // a010: null,
        // a011: null,
        // a100: null,
        // a101: null,
        // a102: null,
        // a104: null,
        // a103: null,
        // a200: null,
        // a203: null,
        // a204: null,
        // a205: null,
        // a206: null,
        // a207: null,
        // a208: null,
        // a209: null,
        // a210: null,
        // a298: null,
        // a300: null,
        // a301: null,
        // a302: null,
        // a304: null,
        // a305: null,
        // a309: null,
        // a310: null,
        // a311: null,
        // a330: null,
        // a331: null,
        // a390: null,
        // a409: null,
        // a448: null,
        // a461: null,
        // a462: null,
        // a502: null,
        // a505: null,
        // a800: null,
        // a805: null,
        // a807: null,
        // a808: null,
        // a820: null,
        // a821: null,
        // a823: null,
        // a824: null,
        // a825: null,
        // a826: null,
        // a835: null,
        // a840: null,
        // a837: null,
        // a845: null,
        // a846: null,
        // a847: null,
        // a850: null,
        // a860: null,
        // a861: null,
        // a863: null,
        // a864: null,
        // a865: null,
        // a866: null,
        // a870: null,
        // a871: null,
        // a885: null,
        // a886: null,
        // a890: null,
        // a891: null,
        // a892: null,
        // a893: null,
      },
      // 表单校验
      rules: {
        nickName: [
          { required: true, message: "用户昵称不能为空", trigger: "blur" }
        ],
      },
      // 表单参数
      form: {},
      // 规范性引用文件
      formStruct: {
        //规范性引用文件
        referenceFiles: [
          // { nDocum: '' }
        ],
        //附录
        fuluList: [
          // { appId: '',appBody: '' } 
        ],
        //参考文献
        cankaoList: [
          // { refItem: '' }
        ],
        //引言
        yinyanList: [
          // {introduction: ''}
        ],
        //术语
        shuyuList: [
          // { tId: '',tCn: '',tEn: '',tDef: '',tNote: '',tExp: '' } 
        ],
        //目次
        muciList:[
          // { clgId: '',clgName: '' }
        ],
        // 结构化数据
        jiegouList: [
          // { techLevel: '' ,techItid: '',techItname: '',techPtbody: '' } 
        ]
      },
      // 表单校验
      rules: {
        a100: [
          { required: true, message: "标准号不能为空", trigger: "blur" }
        ],
        a101: [
          { required: true, message: "发布日期不能为空", trigger: "blur" }
        ],
        a200: [
          { required: true, message: "标准状态不能为空", trigger: "blur" }
        ],
        a205: [
          { required: true, message: "实施日期不能为空", trigger: "blur" }
        ],
        a209: [
          { required: true, message: "起草单位不能为空", trigger: "blur" }
        ],
        a298: [
          { required: true, message: "中文标准名称不能为空", trigger: "blur" }
        ],
        a302: [
          { required: true, message: "英文标准名称不能为空", trigger: "blur" }
        ],
        a310: [
          { required: true, message: "价格不能为空", trigger: "blur" }
        ],
        a825: [
          { required: true, message: "中标分类号不能为空", trigger: "blur" }
        ],
        a826: [
          { required: true, message: "国际标准分类号不能为空", trigger: "blur" }
        ],
      },
      // pdf路径
      pageTotal: null,
      pdfUrl: "",
      structPdfUrl: '',
      // 动态高度变量
      iframeHeight: 2100
    };
  },
  components: { pdf },
  created() {
    this.getList();
    this.getTotal();
  },
  watch: {
    'form.filePath'(newVal, oldVal) {
      console.log("文本路径------------"+newVal)
      if(newVal==null ){
        this.pdfUrl = ''
      }else if(newVal.startsWith('http')){
        this.pdfUrl = newVal
      }else{
        this.pdfUrl = "http://192.168.1.132:9005"+"/dev"+newVal
        // this.pdfUrl = "http://127.0.0.1:9000"+"/dev"+newVal
      }
      // this.form.a893 = "http://192.168.1.132:8075"+newVal
      // console.log(this.pdfUrl)
      // console.log(this.form.a893)
    },
    'structPdfUrl'(newVal, oldVal) {
      console.log("文本路径------------"+newVal)
      if(newVal==null ){
        this.structPdfUrl = ''
      }else if(newVal.startsWith('http')){
        this.structPdfUrl = newVal
      }else{
        this.structPdfUrl = "http://192.168.1.132:9005"+"/dev"+newVal
        // this.pdfUrl = "http://127.0.0.1:9000"+"/dev"+newVal
      }
      // this.form.a893 = "http://192.168.1.132:8075"+newVal
      // console.log(this.pdfUrl)
      // console.log(this.form.a893)
    }
  },
  methods: {
    /** 查询Standard列表 */
    getList() {
      this.loading = true;
      listStandard(this.queryParams).then((response)=>{
        console.log(response)
        this.db15List = response.rows;
        this.total = response.total;
        this.loading = false;
      })

      // listDb15(this.queryParams).then((response) => {
      //   this.db15List = response.rows;
      //   this.total = response.total;
      //   this.loading = false;
      // });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    cancelStruct() {
      this.structopen = false;
      this.resetStruct();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        a000: null,
        a001: null,
        a003: null,
        a010: null,
        a011: null,
        a100: null,
        a101: null,
        a102: null,
        a104: null,
        a103: null,
        a200: null,
        a203: null,
        a204: null,
        a205: null,
        a206: null,
        a207: null,
        a208: null,
        a209: null,
        a210: null,
        a298: null,
        a300: null,
        a301: null,
        a302: null,
        a304: null,
        a305: null,
        a309: null,
        a310: null,
        a311: null,
        a330: null,
        a331: null,
        a390: null,
        a409: null,
        a448: null,
        a461: null,
        a462: null,
        a502: null,
        a505: null,
        a800: null,
        a805: null,
        a807: null,
        a808: null,
        a820: null,
        a821: null,
        a823: null,
        a824: null,
        a825: null,
        a826: null,
        a835: null,
        a840: null,
        a837: null,
        a845: null,
        a846: null,
        a847: null,
        a850: null,
        a860: null,
        a861: null,
        a863: null,
        a864: null,
        a865: null,
        a866: null,
        a870: null,
        a871: null,
        a885: null,
        a886: null,
        a890: null,
        a891: null,
        a892: null,
        a893: null,
        tableName: null,
        table_name: null
      };
      this.resetForm("form");
    },
    resetStruct() {
      this.formStruct = {
        //规范性引用文件
        referenceFiles: [],
        //附录
        fuluList: [],
        //参考文献
        cankaoList: [],
        //引言
        yinyanList: [],
        //术语
        shuyuList: [],
        //目次
        muciList:[],
        // 结构化数据
        jiegouList: []
      };
      this.resetForm("formStruct");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加标准";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getStandard(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改标准";
      });
    },
    handleStruct(row){
      console.log(row)
      const id = row.id || this.ids
      console.log(id)
      this.resetStruct();
      this.structId = id
      this.structopen = true;
      this.structtitle = "添加标准结构化数据";

      //赋值 pdf路径   http://127.0.0.1:9000/dev/%E6%94%B9--202%E5%9F%B9%E8%AE%AD%E6%95%99%E5%AD%A6%E5%BB%BA%E8%AE%BE%E6%96%B9%E6%A1%880408-2.pdf  filePath

      this.structPdfUrl = row.filePath

      // this.structPdfUrl = 'http://127.0.0.1:9000/dev/%E6%94%B9--202%E5%9F%B9%E8%AE%AD%E6%95%99%E5%AD%A6%E5%BB%BA%E8%AE%BE%E6%96%B9%E6%A1%880408-2.pdf'

    },
    /** 修改按钮操作 */
    handleStructUpdate(row) {
      console.log(row)
      this.loading = true;
      this.resetStruct();
      const id = row.id || this.ids;
      this.structPdfUrl = row.filePath
      this.structtitle = "修改标准结构化数据";
      getStandardStructBybid(id).then((response) => {
        console.log(response)
        let data = response.data
        for(let item of data){
            if(item.type == '1'){
              this.formStruct.referenceFiles.push(item)
            }
            if(item.type == '2'){
              this.formStruct.fuluList.push(item)
            }
            if(item.type == '3'){
              this.formStruct.cankaoList.push(item)
            }
            if(item.type == '4'){
              this.formStruct.shuyuList.push(item)
            }
            if(item.type == '5'){
              this.formStruct.muciList.push(item)
            }
            if(item.type == '6'){
              this.formStruct.jiegouList.push(item)
            }
            if(item.type == '7'){
              this.formStruct.yinyanList.push(item)
            }
        }
        this.loading = false;
        this.structopen = true;

      });
    },


    // 添加规范性引用文件
    addGuifan() {
      this.formStruct.referenceFiles.push({ nDocum: '', type: '1', bId: this.structId });
      this.updateIframeHeight();
    },
    
    // 更新iframe高度
    updateIframeHeight() {
      // 延迟一小段时间，确保DOM已经更新
      setTimeout(() => {
        const formContainer = this.$el.querySelector('.el-col[style*="iframeHeight"]');
        if (formContainer) {
          // 获取表单容器的实际高度，增加适当的余量
          const newHeight = Math.max(formContainer.scrollHeight + 50, 2100);
          this.iframeHeight = newHeight;
        }
      }, 100);
    },
    
    // 删除规范性引用文件
    removeGuifan(index) {
      this.formStruct.referenceFiles.splice(index, 1);
    },

    // 新增附录
    addFulu() {
      this.formStruct.fuluList.push( { appId: '',appBody: '', type: '2', bId: this.structId } );
      this.updateIframeHeight();
    },

    // 删除附录
    removeFulu(index) {
      this.formStruct.fuluList.splice(index, 1);
    },

    // 新增参考文献
    addCankao() {
      this.formStruct.cankaoList.push(  { refItem: '', type: '3', bId: this.structId }  );
      this.updateIframeHeight();
    },

    // 删除参考文献
    removeCankao(index) {
      this.formStruct.cankaoList.splice(index, 1);
    },

    // 新增引言
    addYinyan() {
      this.formStruct.yinyanList.push(  { introduction: '', type: '7', bId: this.structId }  );
      this.updateIframeHeight();
    },

    // 删除引言
    removeYinyan(index) {
      this.formStruct.yinyanList.splice(index, 1);
    },

    // 新增术语
    addShuyu() {
      this.formStruct.shuyuList.push(  { tId: '',tCn: '',tEn: '',tDef: '',tNote: '',tExp: '', type: '4', bId: this.structId} );
      this.updateIframeHeight();
    },

    // 删除术语
    removeShuyu(index) {
      this.formStruct.shuyuList.splice(index, 1);
    },


    // 新增目次
    addMuci() {
      this.formStruct.muciList.push( { clgId: '',clgName: '', type: '5', bId: this.structId } );
      this.updateIframeHeight();
    },

    // 删除目次
    removeMuci(index) {
      this.formStruct.muciList.splice(index, 1);
    },

    // 新增结构化内容
    addJieGou() {
      this.formStruct.jiegouList.push( { techLevel: '' ,techItid: '',techItname: '',techPtbody: '', type: '6', bId: this.structId } );
      this.updateIframeHeight();
    },

    // 删除结构化内容
    removeJieGou(index) {
      this.formStruct.jiegouList.splice(index, 1);
    },


    // 提交表单时处理数据
    // submitForm() {
    //   this.$refs.form.validate((valid) => {
    //     if (valid) {
    //       // 提取所有规范性引用文件的值
    //       const references = this.form.referenceFiles.map(item => item.value);
    //       console.log('规范性引用文件:', references);
    //       // 继续处理表单提交逻辑...
    //     } else {
    //       console.log('表单验证失败');
    //       return false;
    //     }
    //   });
    // }

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {

          

          console.log(this.form.filePath)
          if (this.form.id != null) {
            this.form.filePath = "http://192.168.1.132:9005/dev" + this.form.filePath
            updateStandard(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.queryParams.a100 = this.form.a100
              this.getList();
            });
          } else {
            this.form.filePath = "http://192.168.1.132:9005/dev" + this.form.filePath
            addDb15(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.queryParams.a100 = this.form.a100
              this.getList();
            });
          }
        }
      });
    },
    submitStructForm() {
      // if (this.form.id != null) {
      //   updateStandard(this.form).then((response) => {
      //     this.$modal.msgSuccess("修改成功");
      //     this.open = false;
      //     this.getList();
      //   });
      // } else {
      //   addDb15(this.form).then((response) => {
      //     this.$modal.msgSuccess("新增成功");
      //     this.open = false;
      //     this.getList();
      //   });
      // }
      // console.log(this.formStruct)

      const mergedList = []
        .concat(this.formStruct.referenceFiles)
        .concat(this.formStruct.fuluList)
        .concat(this.formStruct.cankaoList)
        .concat(this.formStruct.yinyanList)
        .concat(this.formStruct.shuyuList)
        .concat(this.formStruct.muciList)
        .concat(this.formStruct.jiegouList);
      console.log(mergedList)
       const jsonString = JSON.stringify(mergedList);
      addStandardStructList(jsonString).then((response) => {
        console.log(response)
        this.structopen = false;
      });
    //       console.log('规范性引用文件:', references);
    },
    mergeArrayToString(arr, separator = ';') {
      return arr.map(item => {
        // 将对象转换为字符串，例如 {n_docum: 'xxx'} 转换为 'xxx'
        return Object.values(item).join(' ');
      }).join(separator);
    },
    handleUploadSuccess(response, file, fileList) {
    // 在这里处理上传成功后的逻辑
      console.log('上传成功', response, file, fileList);
      // 例如，更新表单中的 a893 字段
      this.form.a895 = response.url; // 假设 response 中包含文件的 URL
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除Standard编号为"' + ids + '"的数据项？')
        .then(function () {
          return delDb15(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/db15/export",
        {
          ...this.queryParams,
        },
        `db15_${new Date().getTime()}.xlsx`
      );
    },
    // 获取pdf总页数
    getTotal() {
        // 多页pdf的src中不能直接使用后端获取的pdf地址 否则会按页数请求多次数据
        // 需要使用下述方法的返回值作为url
        this.pdfUrl = pdf.createLoadingTask(this.pdfUrl)
        // 获取页码
        this.pdfUrl.promise.then(pdf => this.pageTotal = pdf.numPages).catch(error => {             
        })
    },
    fileFormatter(row, column, cellValue) {
      return cellValue === 1 ? '正常' : '禁用';
    },
    handleFileClick(row, event) {
      // 这里可以添加点击事件的处理逻辑
      // console.log('文件被点击:', row.filePath);
      addDownLog({
        downloadId: row.filePath,
        downloadName: row.filePath,
      }).then((response) => {
        console.log(response)
      })
      // 您可以根据需要添加其他处理逻辑，如记录日志、统计访问量等
      // 由于a标签的默认行为会在新窗口打开链接，这里不需要额外处理跳转
    }
  },
};
</script>
<style scoped>
.large-label .el-form-item__label {
  font-size: 16px; /* 可根据需要调整字体大小 */
  font-weight: 500; /* 可选：增加字体加粗效果 */
}
</style>